﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TB.BLL
{
    public class VisitLog
    {
        private DALFactory.DALFactory dataFactory = DataProvider.DefaultProvider;
        public int InsertLog(TB.Entity.VisitLog obj)
        {
            return dataFactory.DALVisitLogProvider.Insert(obj);
        }

        public string GetVisitedNum(string username, string nickname)
        {//select count(*) as clickNum from VisitLog vl where vl.username='admin' and vl.nickname='迎风渐长'
            string strSql = "";
            if (username == "admin")
            {
                strSql = "select count(*) as clickNum from VisitLog where nickname='" + nickname + "'";
            }
            else
            {
                strSql = "select count(*) as clickNum from VisitLog where username='" + username + "' and nickname='" + nickname + "'";
            }
            System.Data.DataSet ds = dataFactory.DALVisitLogProvider.GetDataSet(strSql);
            return ds.Tables[0].Rows[0]["clickNum"].ToString();
        }

        public System.Data.DataSet GetLogDataSet(string username, string nickname)
        {
            string strSql = "";
            if (username == "admin")
            {
                strSql = "select *from VisitLog where nickname='" + nickname + "'";
            }
            else
            {
                strSql = "select *from VisitLog where username='" + username + "' and nickname='" + nickname + "'";
            }
            return dataFactory.DALVisitLogProvider.GetDataSet(strSql);
        }
    }
}
